home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
util
/
wb
/
Amiga_Eyes1_1a.lha
/
EyesSource1.1a.lha
/
EyesDrawing.c
< prev
Wrap
C/C++ Source or Header
|
1994-12-02
|
24KB
|
880 lines
/*****************************************************************************/
/* AmigaEyes V1.1a (02/12/1994) */
/* */
/* Author: Stéphane Poirier */
/* Copyright © 1994 Stéphane Poirier. All right reserved */
/* */
/*****************************************************************************/
#include <libraries/commodities.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <graphics/displayinfo.h>
#include <graphics/clip.h>
#include <graphics/view.h>
#include <graphics/layers.h>
#include <graphics/copper.h>
#include <graphics/regions.h>
#include <graphics/rastport.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/gels.h>
#include <graphics/gfxbase.h>
#include <clib/graphics_protos.h>
#include <clib/exec_protos.h>
#include <exec/memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <mffp.h>
#include "eyes.h"
/*
** Dessin des yeux
*/
#ifdef ENTRELACE
int eyeX[37] = {-1,0,1,-2,-1,0,1,2,-3,-2,-1,0,1,2,3,-3,-2,-1,0,1,2,3,-3,-2,-1,0,1,2,3,-2,-1,0,1,2,-1,0,1};
int eyeY[37] = {-3,-3,-3,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,3,3,3};
#else
int eyeX[29] = {-1,0,1,-3,-2,-1,0,1,2,3,-4,-3,-2,-1,0,1,2,3,4,-3,-2,-1,0,1,2,3,-1,0,1};
int eyeY[29] = {-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2};
#endif
float dcos[]= { 0.999999, 0.998027, 0.992115, 0.982287, 0.968583, 0.951057, 0.929777,
0.904827, 0.876307, 0.844328, 0.809017, 0.770513, 0.728969, 0.684547,
0.637424, 0.587785, 0.535827, 0.481754, 0.425779, 0.368125, 0.309017,
0.248690, 0.187381, 0.125333, 0.062790, 0.000000 };
UBYTE *pixel; /* Pointeur sur le tableau de flags de la fenetre */
UBYTE Bit[] = {0x80, 0x40, 0x20, 0x10,
0x8, 0x4, 0x2, 0x1 };
struct Trace
{
ULONG Adr[WNDY][8]; /* Adresse des lignes d'écran */
ULONG Adr1[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr2[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr3[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr4[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr5[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr6[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr7[WNDY]; /* Adresse des lignes d'écran */
ULONG Adr8[WNDY]; /* Adresse des lignes d'écran */
short Depth; /* Profondeur de l'écran */
} Trace;
struct BitMap *SBitmap; /* La structure SuperBitMap pour la fenetre */
extern BOOL Restart;
void WriteEye(struct Window *, int , int , int , int, int, int, BOOL);
void ClearEye(struct Window *, int , int , int , int, int, int);
BOOL TestWritePixel(int , int , int , int);
BOOL TestClearPixel(int , int , int , int);
BOOL FermePupilleGauche(struct Window *, int, int *);
BOOL OuvrePupilleGauche(struct Window *, int, int *);
BOOL FermePupilleDroite(struct Window *, int, int *);
BOOL OuvrePupilleDroite(struct Window *, int, int *);
void Plot(struct Window *, register SHORT, register SHORT, register int);
extern struct parametres Parametres;
extern unsigned int clockInit[];
extern USHORT refresh;
/*****************************************************************************/
int EyeCloseWindow(void)
{
FreeMem(pixel, SIZEWNDX*SIZEWNDY); /* Libere la memoire allouée */
return( FALSE);
}
/*****************************************************************************/
void InitPlot(struct Window *EyeWnd, struct BitMap *SBitmap)
{
PLANEPTR plan; /* Pointeur sur un plan de bits */
ULONG addoffset, i;
int y;
UWORD ligne;
Trace.Depth = SBitmap->Depth; /* Profondeur de l'écran */
ligne = WNDX >> 4; /* Calcul de l'adresse du début de chaque ligne */
if (ligne & 1)
ligne ++;
ligne = ligne << 4;
for(y = 0; y < WNDY; y++)
{
addoffset = (ligne * y) >> 3;
for (i = 0; i < Trace.Depth; i++)
{
plan = SBitmap->Planes[i]; /* Adresses des plans ds la SuperBitmap */
Trace.Adr[y][i] = (ULONG)plan + addoffset;
}
Trace.Adr1[y] = Trace.Adr[y][0];
Trace.Adr2[y] = Trace.Adr[y][1];
Trace.Adr3[y] = Trace.Adr[y][2];
Trace.Adr4[y] = Trace.Adr[y][3];
Trace.Adr5[y] = Trace.Adr[y][4];
Trace.Adr6[y] = Trace.Adr[y][5];
Trace.Adr7[y] = Trace.Adr[y][6];
Trace.Adr8[y] = Trace.Adr[y][7];
}
}
/*****************************************************************************/
void InitEyes(struct Window *EyeWnd, struct BitMap *SBitmap)
{
unsigned int clock[2]; /* Horloge */
int x;
SetRast(EyeWnd->RPort,Parametres.fenetre); /* Vide la SuperBitMap */
SetAPen(EyeWnd->RPort,Parametres.bord); /* Couleur du crayon */
#ifdef ENTRELACE
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,15);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,14);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,15);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,14);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,15);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,15);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,14);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,14);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,14);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,14);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,15);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,15);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,15);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,15);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,13);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,13);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,14);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,14);
#else
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,17,8); /* Dessine le contour des yeux */
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,17,8);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,7);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,7);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,7);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,7);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,8);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,8);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,8);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,8);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,8);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,8);
DrawEllipse(EyeWnd->RPort,lEYE,yEYE,18,8);
DrawEllipse(EyeWnd->RPort,rEYE,yEYE,18,8);
#endif
x = timer(clock); /* Prépare la génération de nombres aléatoires */
srand(clock[1]);
/* Allocation d'un tableau de flags représentant l'état de la SuperBitMap */
if((pixel = (UBYTE *)AllocMem(SIZEWNDX*SIZEWNDY,MEMF_PUBLIC|MEMF_CLEAR)) == NULL)
printf("erreur d'allocation mémoire\n");
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer);
SyncSBitMap(EyeWnd->WLayer);
UnlockLayerRom(EyeWnd->WLayer);
}
}
/*****************************************************************************/
/* Routine de gestion des yeux */
/*****************************************************************************/
BOOL DrawingEyes(struct Window *EyeWnd, struct BitMap *SBitmap, int offy)
{
BOOL reveil = FALSE; /* Valeur de retour: y-a-t-il eu arret de la souris */
/* puis mvt ? */
static int xr, yr, xl, yl, mx, my;
static int compteur_clin_d_oeil_gauche = 0; /* Compteurs pour clins d'oeil */
static int compteur_clin_d_oeil_droit = 0;
static unsigned int wait_cligne_gauche = 02; /* Delais pour clins d'oeil */
static unsigned int wait_cligne_droit = 02;
float dr, dl, dxl, dxr, dy, x,y;
int tx, TempsEcoule;
unsigned int clockVal[2];
unsigned int xx, yy,i;
static BOOL debut = TRUE; /* Premier passage dans la routine */
static BOOL ferme_pupilles = FALSE; /* Pupilles fermantes = VRAI sinon FAUX */
static BOOL ouvre_pupilles = FALSE; /* Pupilles ouvrante ... */
static BOOL cligne_gauche = FALSE; /* Clin d'oeil gauche en cours */
static BOOL decligne_gauche = FALSE; /* "Dé"clin d'oeil gauche en cours */
static BOOL cligne_droit = FALSE; /* Idem oeil droit */
static BOOL decligne_droit = FALSE;
static BOOL pupille_fermee = FALSE; /* Pupilles fermées */
static int rRayon = +(REYE-2); /* Rayon des ellipse pour tracer paupieres */
static int lRayon = +(REYE-2);
if (Restart)
{
ferme_pupilles = FALSE;
ouvre_pupilles = FALSE;
cligne_gauche = TRUE;
decligne_gauche = FALSE;
cligne_droit = TRUE;
decligne_droit = FALSE;
pupille_fermee = FALSE;
}
/* Est-ce qu'on est pas en train d'ouvrir ou fermer une pupille, ou est-ce
** les pupilles ne sont pas deja fermees ?
*/
tx = timer(clockVal);
TempsEcoule = clockVal[0] - clockInit[0];
if ((!pupille_fermee) && (!ouvre_pupilles) && (!ferme_pupilles))
{
if (TempsEcoule > Parametres.timeout) /* Si la souris n'a pas bougé */
ferme_pupilles = TRUE; /* durant le temps definit alors on ferme les pupilles */
compteur_clin_d_oeil_gauche++; /* Incrémenter le compteur pour clin d'oeil */
/* Est-on prêt à cligner de l'oeil ? et n'est-on pas en train de fermer les
** pupilles ?
*/
if ((compteur_clin_d_oeil_gauche >= wait_cligne_gauche) && (!ferme_pupilles))
cligne_gauche = TRUE;
if(decligne_gauche) /* releve la paupiere */
{
for(i = 0; i<REYE*2; i++)
{
decligne_gauche = (!OuvrePupilleGauche(EyeWnd, Parametres.fond, &lRayon));
WriteEye(EyeWnd, xl, yl, xl, yl, Parametres.pupille,
Parametres.paupiere, decligne_gauche); /* retrace pupille */
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
if (!decligne_gauche) break;
}
decligne_gauche = FALSE;
wait_cligne_gauche = (((unsigned int)rand() >> 23) + (1 << 8))
/ refresh;
}
if(cligne_gauche)
{
for(i = 0; i<2*REYE; i++)
{
cligne_gauche = (!FermePupilleGauche(EyeWnd, Parametres.paupiere, &lRayon));
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
if (!cligne_gauche) break;
}
decligne_gauche = TRUE;
cligne_gauche = FALSE;
compteur_clin_d_oeil_gauche = 0;
}
compteur_clin_d_oeil_droit++;
if ((compteur_clin_d_oeil_droit >= wait_cligne_droit) && (!ferme_pupilles))
cligne_droit = TRUE;
if(decligne_droit)
{
for(i = 0; i<REYE*2; i++)
{
decligne_droit = (!OuvrePupilleDroite(EyeWnd, Parametres.fond, &rRayon));
WriteEye(EyeWnd, xr, yr, xr, yr, Parametres.pupille,
Parametres.paupiere, decligne_droit);
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
if (!decligne_droit) break;
}
decligne_droit = FALSE;
wait_cligne_droit = (((unsigned int)rand() >> 23) + (1 << 8))
/ refresh;
}
if(cligne_droit)
{
for(i = 0; i<2*REYE; i++)
{
cligne_droit = (!FermePupilleDroite(EyeWnd, Parametres.paupiere, &rRayon));
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
if (!cligne_droit) break;
}
decligne_droit = TRUE;
cligne_droit = FALSE;
compteur_clin_d_oeil_droit = 0;
}
}
if (ferme_pupilles)
{
ferme_pupilles = (!FermePupilleGauche(EyeWnd, Parametres.paupiere, &lRayon));
ferme_pupilles = (!FermePupilleDroite(EyeWnd, Parametres.paupiere, &rRayon));
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
pupille_fermee = !ferme_pupilles;
}
if (ouvre_pupilles)
{
ouvre_pupilles = (!OuvrePupilleGauche(EyeWnd, Parametres.fond, &lRayon));
ouvre_pupilles = (!OuvrePupilleDroite(EyeWnd, Parametres.fond, &rRayon));
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
WriteEye(EyeWnd, xl, yl, xl, yl, Parametres.pupille,
Parametres.paupiere, ouvre_pupilles);
WriteEye(EyeWnd, xr, yr, xr, yr, Parametres.pupille,
Parametres.paupiere, ouvre_pupilles);
}
if ((EyeWnd->MouseX != mx + OFFX) || (EyeWnd->MouseY != my + offy))
{
if (TempsEcoule > 1) /* On renvoie "reveil" si 1 sec au moins */
reveil = TRUE; /* s'est ecoulée depuis le dernier mvt. */
clockInit[1] = clockVal[1];
clockInit[0] = clockVal[0];
refresh = Parametres.refresh;
if((ferme_pupilles) || (pupille_fermee))
{
ouvre_pupilles = TRUE;
ferme_pupilles = FALSE;
pupille_fermee = FALSE;
}
mx = EyeWnd->MouseX - OFFX;
my = EyeWnd->MouseY - offy;
dxl = (float)mx - (float)lEYE; /* Distance de la pupille au pointeur */
dxr = (float)mx - (float)rEYE;
#ifdef ENTRELACE
dy = (float)my - (float)yEYE;
#else
dy = ((float)my - (float)yEYE) * 2;
#endif
dl = sqrt(SQR(dxl) + SQR(dy));
dr = sqrt(SQR(dxr) + SQR(dy));
if (dl > RLIM) /* Si distance > rayon de l'oeil */
{
x = (float)RLIM/dl * dxl + (float)lEYE;
#ifdef ENTRELACE
y = (float)RLIM/dl * dy + (float)yEYE;
#else
y = ((float)REYE/dl * dy)/2 + (float)yEYE;
#endif
xx = (int)(x+0.5);
yy = (int)(y+0.5);
}
else /* Sinon Pupille sous le pointeur */
{
xx = mx;
yy = my;
}
if ((xl != xx) || (yl != yy)) /* Si la pupille est déplacée */
{ /* Alors on la redessine */
WriteEye(EyeWnd, xx, yy, xl, yl, Parametres.pupille,
Parametres.paupiere, ouvre_pupilles);
if (debut == FALSE)
ClearEye(EyeWnd, xx, yy, xl, yl, Parametres.fond, Parametres.paupiere);
xl = xx; yl = yy;
}
if (dr > RLIM) /* Idem pupille droite */
{
x = (float)RLIM/dr * dxr + (float)rEYE;
#ifdef ENTRELACE
y = (float)RLIM/dr * dy + (float)yEYE;
#else
y = ((float)REYE/dr * dy)/2 + (float)yEYE;
#endif
xx = (int)(x+0.5);
yy = (int)(y+0.5);
}
else
{
xx = mx;
yy = my;
}
if ((xr != xx) || (yr != yy))
{
WriteEye(EyeWnd, xx, yy, xr, yr, Parametres.pupille,
Parametres.paupiere, ouvre_pupilles);
if (debut == FALSE)
ClearEye(EyeWnd, xx, yy, xr, yr, Parametres.fond, Parametres.paupiere);
xr = xx; yr = yy;
}
if (Parametres.drawing == CUSTOM_DRAW)
{
LockLayerRom(EyeWnd->WLayer); /* Recopie dans la bitmap de */
CopySBitMap(EyeWnd->WLayer); /* l'ecran la derniere opération */
UnlockLayerRom(EyeWnd->WLayer); /* graphique */
}
}
else
{
if (TempsEcoule >= 1) /* Si la souris n'a pas bougé */
{
refresh = SLEEP; /* pendant au moins 1 sec. */
}
}
debut = FALSE;
return (reveil);
}
/*****************************************************************************/
/* Dessine une pupille */
/*****************************************************************************/
void WriteEye(struct Window *EyeWnd, int x, int y,
int xold, int yold, int c1, int c2, BOOL ouvre_pupille)
{
register int i, x1, y1;
UBYTE *c;
SetAPen(EyeWnd->RPort,c1);
#ifdef ENTRELACE
for (i=0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
#else
for (i=0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
#endif
{
x1 = x+eyeX[i];
y1 = y+eyeY[i];
c = pixel+SIZEWNDX*x1+y1;
if ((*c != c2) && (*c != c1)) /* Si le point n'est pas deja affiché */
{
Plot(EyeWnd, x1, y1, c1);
*c = c1;
}
}
}
/*****************************************************************************/
/* Efface une pupille */
/*****************************************************************************/
void ClearEye(struct Window *EyeWnd, int x, int y, int xold, int yold, int c1, int c2)
{
register int i, x1, y1;
UBYTE *c;
SetAPen(EyeWnd->RPort,c1);
#ifdef ENTRELACE
for (i = 0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
#else
for (i = 0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
#endif
{
x1 = xold+eyeX[i];
y1 = yold+eyeY[i];
c = pixel+SIZEWNDX*x1+y1;
if (!TestClearPixel(x1, y1, x, y))
if (*c != c2)
{
Plot(EyeWnd, x1, y1, c1);
*c = c1;
}
}
}
/*****************************************************************************/
/* Test pour déterminer si on peut effacer un pixel */
/*****************************************************************************/
BOOL TestClearPixel(int x, int y, int xnew, int ynew)
{
register int i;
BOOL ret = FALSE;
#ifdef ENTRELACE
for (i = 0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
#else
for (i = 0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
#endif
{
if ((x == xnew + eyeX[i]) && (y == ynew + eyeY[i]))
{
ret = TRUE;
break;
}
}
return(ret);
}
/*****************************************************************************/
BOOL FermePupilleGauche(struct Window *EyeWnd, int c, int * PRayon)
{
SHORT i, xp, yp;
#ifdef ENTRELACE
static float rx = REYE-0.5;
#else
static float rx = 2*REYE+0.5;
#endif
float ry, x, y;
float sgn = 1;
if (*PRayon < 0)
{
sgn = -1;
ry = -(*PRayon);
}
else
{
ry = *PRayon;
}
SetAPen(EyeWnd->RPort, c);
for (i = 0; i <= RESOL; i++)
{
x = (float)rx * sgn*dcos[i];
y = -(float)ry * sgn*dcos[RESOL-i];
xp = (int)(x+0.5+lEYE);
yp = (int)(y+0.5+yEYE);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
xp = (int)(-x+0.5+lEYE);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
}
(*PRayon)--;
#ifdef ENTRELACE
if (*PRayon < -(REYE-2))
#else
if (*PRayon < -(REYE-1))
#endif
{
(*PRayon)++;
return(TRUE);
}
else
return(FALSE);
}
/*****************************************************************************/
BOOL OuvrePupilleGauche(struct Window *EyeWnd, int c, int *PRayon)
{
SHORT i, xp, yp;
#ifdef ENTRELACE
static float rx = REYE-0.5;
#else
static float rx = REYE*2+0.5;
#endif
float ry, x, y;
float sgn = 1;
if (*PRayon < 0)
{
sgn = -1;
ry = -*PRayon;
}
else
{
ry = *PRayon;
}
SetAPen(EyeWnd->RPort, c);
for (i = 0; i <= RESOL; i++)
{
x = (float)rx * sgn*dcos[i];
y = -(float)ry * sgn*dcos[RESOL-i];
xp = (int)(x+lEYE+0.5);
yp = (int)(y+yEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
xp = (int)(-x+lEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
}
(*PRayon)++;
#ifdef ENTRELACE
if (*PRayon > (REYE-2))
#else
if (*PRayon > (REYE-1))
#endif
{
(*PRayon)--;
return(TRUE);
}
else
return(FALSE);
}
/*****************************************************************************/
BOOL FermePupilleDroite(struct Window *EyeWnd, int c, int * PRayon)
{
SHORT i, xp, yp;
#ifdef ENTRELACE
static float rx = REYE-0.5;
#else
static float rx = REYE*2+0.5;
#endif
float ry, x, y;
float offsetangle = 0;
float sgn = 1;
if (*PRayon < 0)
{
offsetangle = PI;
sgn = -1;
ry = -(*PRayon);
}
else
{
ry = *PRayon;
}
SetAPen(EyeWnd->RPort, c);
for (i = 0; i <= RESOL; i++)
{
x = (float)rx * sgn*dcos[i];
y = -(float)ry * sgn*dcos[RESOL-i];
xp = (int)(x+rEYE+0.5);
yp = (int)(y+yEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
xp = (int)(-x+rEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
}
(*PRayon)--;
#ifdef ENTRELACE
if (*PRayon < -(REYE-2))
#else
if (*PRayon < -(REYE-1))
#endif
{
(*PRayon)++;
return(TRUE);
}
else
return(FALSE);
}
/*****************************************************************************/
BOOL OuvrePupilleDroite(struct Window *EyeWnd, int c, int *PRayon)
{
SHORT i, xp, yp;
#ifdef ENTRELACE
static float rx = REYE-0.5;
#else
static float rx = REYE*2+0.5;
#endif
float ry, x, y;
float offsetangle = 0;
float sgn = 1;
if (*PRayon < 0)
{
offsetangle = PI;
sgn = -1;
ry = -*PRayon;
}
else
{
ry = *PRayon;
}
SetAPen(EyeWnd->RPort, c);
for (i = 0; i <= RESOL; i++)
{
x = (float)rx * sgn*dcos[i];
y = -(float)ry * sgn*dcos[RESOL-i];
xp = (int)(x+rEYE+0.5);
yp = (int)(y+yEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
xp = (int)(-x+rEYE+0.5);
Plot(EyeWnd, xp, yp, c);
*(pixel+SIZEWNDX*xp+yp) = c;
}
(*PRayon)++;
#ifdef ENTRELACE
if (*PRayon > (REYE-2))
#else
if (*PRayon > (REYE-1))
#endif
{
(*PRayon)--;
return(TRUE);
}
else
return(FALSE);
}
/*****************************************************************************/
/* Routine d'affichage d'un point */
/*****************************************************************************/
void Plot(struct Window *EyeWnd, register SHORT x, register SHORT y, register int c)
{
register UBYTE *adresse;
register etbit, oubit;
register ULONG addoffset;
if (Parametres.drawing == CUSTOM_DRAW)
{
if ((x <= EyeWnd->Width) && (y <= EyeWnd->Height))
{
addoffset = x >> 3;
oubit = Bit[x & 7];
etbit = 255 - oubit;
adresse = (UBYTE *)(Trace.Adr1[y] + addoffset);
if (c & 1)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 1)
{
adresse = (UBYTE *)(Trace.Adr2[y] + addoffset);
if (c & 2)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 2)
{
adresse = (UBYTE *)(Trace.Adr3[y] + addoffset);
if (c & 4)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 3)
{
adresse = (UBYTE *)(Trace.Adr4[y] + addoffset);
if (c & 8)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 4)
{
adresse = (UBYTE *)(Trace.Adr5[y] + addoffset);
if (c & 16)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 5)
{
adresse = (UBYTE *)(Trace.Adr6[y] + addoffset);
if (c & 32)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 6)
{
adresse = (UBYTE *)(Trace.Adr7[y] + addoffset);
if (c & 64)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
if (Trace.Depth > 7)
{
adresse = (UBYTE *)(Trace.Adr8[y] + addoffset);
if (c & 128)
*(adresse) |= oubit;
else
*(adresse) &= etbit;
}
}
}
}
}
}
}
}
}
else
{
WritePixel(EyeWnd->RPort, x, y);
}
}